//
//  HLEMarchs.h
//  HandheldELearn
//
//  Created by wsj2015 on 16/7/11.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#ifndef HLEMarchs_h
#define HLEMarchs_h

#import "HELAppManager.h"
#import "HELNetworkManager.h"
#import "MJExtension.h"
#import "MJRefresh.h"
#import "UIScrollView+WSJRefresh_MJ.h"
//window上显示
#define alertMessage(message)   MBProgressHUD *hud = [MBProgressHUD HUDForView:[[UIApplication sharedApplication] keyWindow]]; hud = hud?hud:[MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication] keyWindow] animated:YES]; hud.mode = MBProgressHUDModeText;hud.label.numberOfLines = 0; hud.label.text = message;hud.label.numberOfLines = 0; [hud hideAnimated:YES afterDelay:2.f]

//viewcontroller 里面显示
#define cwqAlertMessage(message)   MBProgressHUD *hud = [MBProgressHUD HUDForView:self.view]; hud = hud?hud:[MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud.mode = MBProgressHUDModeText; hud.label.numberOfLines = 0;hud.label.text = message; [hud hideAnimated:YES afterDelay:1.f]


#define cwqHud(view)  MBProgressHUD *hud = [MBProgressHUD HUDForView:view]; hud = hud?hud:[MBProgressHUD showHUDAddedTo:view animated:YES]; hud.mode = MBProgressHUDModeIndeterminate


#define cwqHudRequestError(message) weakSelf_define; MBProgressHUD *hud = [MBProgressHUD HUDForView:weakSelf.view]; hud = hud?hud:[MBProgressHUD showHUDAddedTo:weakSelf.view animated:YES]; if(message){hud.mode = MBProgressHUDModeText;hud.label.numberOfLines = 0; hud.label.text = message;[hud hideAnimated:YES afterDelay:2];}else{[hud hideAnimated:YES];}


#define cwqHudSuccess(hud)   [hud hideAnimated:YES];

#define cwqHudHidden  MBProgressHUD *hud = [MBProgressHUD HUDForView:[[UIApplication sharedApplication] keyWindow]]; if(hud)[hud hideAnimated:YES];

#define kKeyboardHeight 216

#define kBtnColor HexRGB_WSJ(23, 110, 147)

#define weakSelf_define __weak typeof(self) weakSelf =self
#define defineWeakSelf __weak typeof(self) weakSelf =self
#define HexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define HexRGBAlpha(rgbValue,a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)]
#define HexRGB_WSJ(x,y,z) [UIColor colorWithRed:(x)/255.0 green:(y)/255.0 blue:(z)/255.0 alpha:1.0]

#define kAppBg [UIColor whiteColor]
#define kTxtColor HexRGB(0x5e606d)
#define kBorderColor HexRGB(0xdedede)
#define kMainColor HexRGB_WSJ(16, 89, 130)

#define kScreenHeight   ([UIScreen mainScreen].bounds.size.height)
#define kScreenWidth    ([UIScreen mainScreen].bounds.size.width)
#define kScreenFactor   (kScreenHeight <= 568.0 ? 1.0 : kScreenHeight / 568.0);
#define kScreenFrame    (CGRectMake(0,0,kScreenWidth,kScreenHeight))
#define kWithOutNanBarFrame    (CGRectMake(0,64,kScreenWidth,kScreenHeight-64))
#define kOnePX (1.0/[UIScreen mainScreen].scale)

#define font(x) [UIFont systemFontOfSize:x]
#define wsj_cornerRadius(view,value)   \
view.layer.cornerRadius =value;\
view.layer.masksToBounds = YES\
//中文字体
#define CHINESE_FONT_NAME  @"Heiti SC"
#define CHINESE_SYSTEM(x) [UIFont fontWithName:CHINESE_FONT_NAME size:x]

//不同屏幕尺寸字体适配（320，568是因为效果图为IPHONE5 如果不是则根据实际情况修改）
#define kScreenWidthRatio  (Main_Screen_Width / 320.0)
#define kScreenHeightRatio (Main_Screen_Height / 568.0)
#define AdaptedWidth(x)  ceilf((x) * kScreenWidthRatio)
#define AdaptedHeight(x) ceilf((x) * kScreenHeightRatio)
#define AdaptedFontSize(R)     CHINESE_SYSTEM(AdaptedWidth(R))

#define UNICODETOUTF16(x) (((((x - 0x10000) >>10) | 0xD800) << 16)  | (((x-0x10000)&3FF) | 0xDC00))
#define MULITTHREEBYTEUTF16TOUNICODE(x,y) (((((x ^ 0xD800) << 2) | ((y ^ 0xDC00) >> 8)) << 8) | ((y ^ 0xDC00) & 0xFF)) + 0x10000

// App Frame Height&Width
#define App_Frame_Height        [[UIScreen mainScreen] applicationFrame].size.height
#define App_Frame_Width         [[UIScreen mainScreen] applicationFrame].size.width

//获取View的属性
#define GetViewWidth(view)  view.frame.size.width
#define GetViewHeight(view) view.frame.size.height
#define GetViewX(view)      view.frame.origin.x
#define GetViewY(view)      view.frame.origin.y

// MainScreen Height&Width
#define Main_Screen_Height      [[UIScreen mainScreen] bounds].size.height
#define Main_Screen_Width       [[UIScreen mainScreen] bounds].size.width

// 字体大小(常规/粗体)
#define BOLDSYSTEMFONT(FONTSIZE)[UIFont boldSystemFontOfSize:FONTSIZE]
#define SYSTEMFONT(FONTSIZE)    [UIFont systemFontOfSize:FONTSIZE]
#define FONT(NAME, FONTSIZE)    [UIFont fontWithName:(NAME) size:(FONTSIZE)]

// 当前版本
#define FSystemVersion          ([[[UIDevice currentDevice] systemVersion] floatValue])
#define DSystemVersion          ([[[UIDevice currentDevice] systemVersion] doubleValue])
#define SSystemVersion          ([[UIDevice currentDevice] systemVersion])

// 是否大于等于IOS7
#define isIOS7                  ([[[UIDevice currentDevice]systemVersion]floatValue] >= 7.0)
// 是否IOS6
#define isIOS6                  ([[[UIDevice currentDevice]systemVersion]floatValue] < 7.0)
// 是否大于等于IOS8
#define isIOS8                  ([[[UIDevice currentDevice]systemVersion]floatValue] >=8.0)
// 是否大于IOS9
#define isIOS9                  ([[[UIDevice currentDevice]systemVersion]floatValue] >=9.0)
// 是否iPad
#define isPad                   (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)


#ifdef DEBUG

#define Log(xx, ...) NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

#else

#define Log(xx, ...)

#endif

#endif /* HLEMarchs_h */
